<?php
/**
 * Created by PhpStorm.
 * User: FEIFEI
 * Date: 2018/7/30
 * Time: 10:02
 */

namespace App\Http\Controllers;
use App\Common\lib\Util;
use Illuminate\Http\Request;
use DB;
class RecommendedUsersController extends Controller{
    //B端用户
    public function B_list(Request $request){

        if ( $request->ajax() ) {

            if ( isset( $request->startDate ) ) {
                $url = "/api/clientuser/reference/b?page=".$request->page."&rows=".$request->rows."&startDate=".$request->startDate."&endDate=".$request->endDate;
            } elseif ( isset( $request->like ) ) {
                $url = "/api/clientuser/reference/b?page=".$request->page."&rows=".$request->rows."&like=".$request->like;
//                dump(DB::getQueryLog());
            } else {
                $url = "/api/clientuser/reference/b?page=".$request->page."&rows=".$request->rows;
            }
            $response = Util::toCurl($url, [], 20);
            $data = json_decode($response, true);
            return $data;
//            var_dump($data);

        }else{
            return view('recommendedUsers.check_admin_list');
        }

    }


    //C端用户
    public function C_list(Request $request){

        if ( $request->ajax() ) {

            if ( isset( $request->startDate ) && empty($request->rank) ) {
                $url = "/api/clientuser/reference/c?page=".$request->page."&rows=".$request->rows."&startDate=".$request->startDate."&endDate=".$request->endDate;
            } elseif ( isset( $request->like ) ) {
                $url = "/api/clientuser/reference/c?page=".$request->page."&rows=".$request->rows."&like=".$request->like;
//                dump(DB::getQueryLog());
            } elseif ( isset( $request->pid ) ) {
                $url = "/api/clientuser/reference/c?page=".$request->page."&rows=".$request->rows."&pid=".$request->pid;
//                dump(DB::getQueryLog());
            }elseif ( isset( $request->rank )  && empty($request->startDate)  ) {
                $url = "/api/clientuser/reference/c?page=".$request->page."&rows=".$request->rows."&rank=".$request->rank;
//
            } elseif ( isset( $request->rank )&& isset( $request->startDate )) {

                $url = "/api/clientuser/reference/c?page=".$request->page."&rows=".$request->rows."&rank=".$request->rank."&startDate=".$request->startDate."&endDate=".$request->endDate;
//
            }else {
                $url = "/api/clientuser/reference/c?page=".$request->page."&rows=".$request->rows;
            }
            $response = Util::toCurl($url, [], 20);
            $data = json_decode($response, true);
            return $data;
//            var_dump($data);

        }else{
            return view('recommendedUsers.check_admin_list_c');
        }

    }










}